﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HumanManagement.BusinessLogic;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace BSC_HumanManagement.Usercontrols
{
    public partial class uc_HoSoNhanVien : System.Web.UI.UserControl
    {
        Code.Staticvariable _objStaticvariable = new Code.Staticvariable();
        int stt = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            _objStaticvariable.CheckPermission(this);
            LoadData();
        }

        private void LoadData()
        {
            PersonalProfileBL objPersonalProfileDA = new PersonalProfileBL();
            DataTable _objDataTable = objPersonalProfileDA.GetDataSet(int.Parse(Session["PersonalProfileID"].ToString()) ).Tables[0];

            //// neu ProfileStatus = 0 --> An di, nguoc lai 
            //for (int i = _objDataTable.Rows.Count - 1; i >= 0; i--)
            //{
            //    if (_objDataTable.Rows[i]["ProfileStatus"].Equals("0")) _objDataTable.Rows.RemoveAt(i);
            //}

            
            //// nếu là Staff, chỉ xem đc của bản thân
            //if (Session["UserOrStaff"].ToString() == "Staff")
            //{
            //    for (int i = _objDataTable.Rows.Count - 1; i >= 0; i--)
            //    {
            //        if (_objDataTable.Rows[i]["ID"].ToString().Equals(Session["PersonalProfileID"].ToString()) == false) _objDataTable.Rows.RemoveAt(i);
            //    }
            //}
            //// nếu là User, load hết nhân viên, nếu là chi nhánh chỉ xem đc của chi nhánh
            //else
            //{
            //    if (Session["BranchID"].Equals(2))
            //    {
            //        for (int i = _objDataTable.Rows.Count - 1; i >= 0; i--)
            //        {
            //            if(_objDataTable.Rows[i]["BranchID"].Equals("2")) _objDataTable.Rows.RemoveAt(i);
            //        }
            //    }
            //}
            // Neu la Staff binh thuong, chi cho xem ban than ca nhan
            this._GridView.DataSource = _objDataTable;
            this._GridView.DataBind();
        }

        protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this._GridView.PageIndex = e.NewPageIndex;
            this._GridView.DataBind();
        }

        protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                stt++;
                Label lblSTT = e.Row.Cells[0].FindControl("lblSTT") as Label;
                lblSTT.Text = stt.ToString();
            }
        }

        //public void OnConfirm(object sender, EventArgs e)
        //{
        //    string confirmValue = Request.Form["confirm_value"];
        //    if (confirmValue == "Yes")
        //    {
        //        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true);
        //    }
        //    else
        //    {
        //        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
        //    }
        //}
    }
}